package com.songcan.basics.core.controller;


import com.songcan.basics.core.service.IndustryCateGoryService;
import com.songcan.model.basics.IndustryCategory;
import lombok.AllArgsConstructor;
import org.omg.CORBA.PUBLIC_MEMBER;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;


/**
 * 银行进件分类管理
 */
@AllArgsConstructor
@RestController
@RequestMapping("/rest/industry")
public class IndustryCategoryController {

    private final IndustryCateGoryService industryCateGoryService;



    @PostMapping()
    public void addIndustry(@NotBlank(message = "名称不能为空")String name,
                            @NotBlank(message = "对应银行分类编码不能为空")String bankTypeCode,
                            String remark,String bankCode,Long pid){
          industryCateGoryService.addIndustryGateGory(name,remark,bankCode,bankTypeCode,pid);
    }

    @PutMapping()
    public void  updateIndustry(@NotNull(message = "id不能为空")Long id,String name,String bankTypeCode,
                                String remark,String bankCode,Long pid,Integer status){
         IndustryCategory industryCategory = new IndustryCategory(id,name,null,status,remark,null,bankCode,bankTypeCode,pid);
         industryCateGoryService.saveOrUpdate(industryCategory);
    }

    @GetMapping()
    public IndustryCategory getById(@NotNull String id){
        return  industryCateGoryService.getById(id);
    }


}
